package com.aqie.easy.bitOperation;

/**
 * 405 十进制转十六进制  todo
 *  a  b  c  d  e  f
 *  10 11 12 13 14 15
 */
public class ToHex {
    public String toHex(int num) {
        if (num == 0) return "0";
        String hex = "0123456789abcdef", ans = "";
        while(num != 0 && ans.length() < 8){
            ans = hex.charAt(num & 0xf) + ans;
            num >>=  4;
        }
        return ans;
    }

    public static void main(String[] args) {
        int num = 25;
        num = -1;
        System.out.println(new ToHex().toHex(num));
    }
}
